######################## Replication codes for Huikuri and Shim ISQ ########################
####################### Results are produced under STATA/MP 18.0  #########################

#################### First-stage regression - Model 1 in Table 3 ###################

use "C:\Users\sujeo\Dropbox\Tuuli and Sujeong projects\Submission\ISQ\Accepted\Replication\Huikuri_Shim_PANEL data.dta", replace


gen IV=gdp_mkt1*avg_BITsigned_neighbors


eststo clear 
eststo: probit signed_bit  c.dem_accountability1##c.prights_vdem2  fdi_inflows_ofgdp1 fdi_inflows_ofgdp2 tradeof_gdp1 tradeof_gdp2 isds_respondent1_cum isds_respondent2_cum bur_quality1 bur_quality2 gov_stability1 gov_stability2 IV


# Estimating selection bias to be used in the main analysis #
predict probitxb, xb
gen pdf=normalden(probitxb)
gen cdf=normal(probitxb)
gen imr=pdf/cdf


################### Opening the main dataset with estimated selection bias (imr3) ####################

use "C:\Users\sujeo\Dropbox\Tuuli and Sujeong projects\Submission\ISQ\Accepted\Replication\Huikuri_Shim_maindataset2025.dta", replace


eststo clear

# Model 2 in Table 3 #
eststo: reg effective_commitment dem_accountability1 prights_vdem2 yo_signature fdi_inflows_ofgdp1 fdi_inflows_ofgdp2 tradeof_gdp1 tradeof_gdp2  isds_respondent1_cum isds_respondent2_cum  bur_quality1 bur_quality2 gov_stability1 gov_stability2 auto_renewal_num ex_security_num ex_healthenv_num ex_other_num ex_prudential_num term_window imr


# Model 3 in Table 3 #

eststo: reg effective_commitment c.dem_accountability1##c.prights_vdem2 yo_signature fdi_inflows_ofgdp1 fdi_inflows_ofgdp2 tradeof_gdp1 tradeof_gdp2  isds_respondent1_cum isds_respondent2_cum  bur_quality1 bur_quality2 gov_stability1 gov_stability2 auto_renewal_num ex_security_num ex_healthenv_num ex_other_num ex_prudential_num term_window imr


esttab using results_2024_ISQ.rtf, replace se  star(* .10 ** .05 *** .01)


############################ Robustness checks #################################


####### Table A2 #########

# Not accounting for selection bias #
eststo clear 

eststo: reg effective_commitment c.dem_accountability1##c.prights_vdem2 polity1 polity2 yo_signature fdi_inflows_ofgdp1 fdi_inflows_ofgdp2 tradeof_gdp1 tradeof_gdp2  isds_respondent1_cum isds_respondent2_cum  bur_quality1 bur_quality2 gov_stability1 gov_stability2 auto_renewal_num ex_security_num ex_healthenv_num ex_other_num ex_prudential_num term_window 

#controlling for regime type #


eststo: reg effective_commitment c.dem_accountability1##c.prights_vdem2 polity1 polity2 yo_signature fdi_inflows_ofgdp1 fdi_inflows_ofgdp2 tradeof_gdp1 tradeof_gdp2  isds_respondent1_cum isds_respondent2_cum  bur_quality1 bur_quality2 gov_stability1 gov_stability2 auto_renewal_num ex_security_num ex_healthenv_num ex_other_num ex_prudential_num term_window imr

eststo: reg effective_commitment c.dem_accountability1##c.prights_vdem2 v2x_libdem1 v2x_libdem2 yo_signature fdi_inflows_ofgdp1 fdi_inflows_ofgdp2 tradeof_gdp1 tradeof_gdp2  isds_respondent1_cum isds_respondent2_cum  bur_quality1 bur_quality2 gov_stability1 gov_stability2 auto_renewal_num ex_security_num ex_healthenv_num ex_other_num ex_prudential_num term_window imr


eststo: reg effective_commitment c.v2x_libdem1##c.prights_vdem2 yo_signature fdi_inflows_ofgdp1 fdi_inflows_ofgdp2 tradeof_gdp1 tradeof_gdp2  isds_respondent1_cum isds_respondent2_cum  bur_quality1 bur_quality2 gov_stability1 gov_stability2 auto_renewal_num ex_security_num ex_healthenv_num ex_other_num ex_prudential_num term_window imr

esttab using apendix_table2.rtf, replace se  star(* .10 ** .05 *** .01)





####### Table A3 #########

## Excluding treaty features ##

eststo clear

eststo: reg effective_commitment c.dem_accountability1##c.prights_vdem2 fdi_inflows_ofgdp1 fdi_inflows_ofgdp2 tradeof_gdp1 tradeof_gdp2  isds_respondent1_cum isds_respondent2_cum  bur_quality1 bur_quality2 gov_stability1 gov_stability2  imr



## with country FE ##

eststo: reg effective_commitment c.dem_accountability1##c.prights_vdem2 yo_signature fdi_inflows_ofgdp1 fdi_inflows_ofgdp2 tradeof_gdp1 tradeof_gdp2  isds_respondent1_cum isds_respondent2_cum  bur_quality1 bur_quality2 gov_stability1 gov_stability2 auto_renewal_num ex_security_num ex_healthenv_num ex_other_num ex_prudential_num term_window imr i.party1_cown i.party2_cown


## DV: exit clauses category ## 

eststo: ologit term_flexibility_num c.dem_accountability1##c.prights_vdem2 yo_signature fdi_inflows_ofgdp1 fdi_inflows_ofgdp2 tradeof_gdp1 tradeof_gdp2  isds_respondent1_cum isds_respondent2_cum  bur_quality1 bur_quality2 gov_stability1 gov_stability2 auto_renewal_num ex_security_num ex_healthenv_num ex_other_num ex_prudential_num term_window imr


esttab using apendix_table3.rtf, replace se  star(* .10 ** .05 *** .01)




####### Table A4 #########


##Importer's economic power ##

gen gdp_difference=gdp_mkt1-gdp_mkt2
sum gdp_difference
gen ln_gdp_difference=log(gdp_difference)
sum ln_gdp_difference

eststo clear
eststo: reg effective_commitment c.dem_accountability1##c.prights_vdem2 polity1 polity2  gdp_pcmkt2 yo_signature fdi_inflows_ofgdp1 fdi_inflows_ofgdp2 tradeof_gdp1 tradeof_gdp2  isds_respondent1_cum isds_respondent2_cum  bur_quality1 bur_quality2 gov_stability1 gov_stability2 auto_renewal_num ex_security_num ex_healthenv_num ex_other_num ex_prudential_num term_window imr

eststo: reg effective_commitment c.dem_accountability1##c.prights_vdem2 ln_gdp_difference polity1 polity2  yo_signature fdi_inflows_ofgdp1 fdi_inflows_ofgdp2 tradeof_gdp1 tradeof_gdp2  isds_respondent1_cum isds_respondent2_cum  bur_quality1 bur_quality2 gov_stability1 gov_stability2 auto_renewal_num ex_security_num ex_healthenv_num ex_other_num ex_prudential_num term_window imr

eststo: reg effective_commitment c.dem_accountability1##c.ln_gdp_difference  c.dem_accountability1##c.prights_vdem2 polity1 polity2  yo_signature fdi_inflows_ofgdp1 fdi_inflows_ofgdp2 tradeof_gdp1 tradeof_gdp2  isds_respondent1_cum isds_respondent2_cum  bur_quality1 bur_quality2 gov_stability1 gov_stability2 auto_renewal_num ex_security_num ex_healthenv_num ex_other_num ex_prudential_num term_window imr

esttab using apendix_table4.rtf, replace se  star(* .10 ** .05 *** .01)



####### Table A5 #########
eststo clear

eststo: reg effective_commitment c.dem_accountability1##c.prights_vdem2 

eststo: reg effective_commitment c.dem_accountability1##c.prights_vdem2  imr

eststo: reg effective_commitment c.dem_accountability1##c.prights_vdem2 yo_signature auto_renewal_num ex_security_num ex_healthenv_num ex_other_num ex_prudential_num term_window imr

esttab using apendix_table5.rtf, replace se  star(* .10 ** .05 *** .01)




####### Table A7 #########

## To get the median value of GDP difference ##
sum ln_gdp_difference, d

eststo clear
eststo: reg effective_commitment dem_accountability1 c.dem_accountability1##c.prights_vdem2 polity1 polity2  yo_signature fdi_inflows_ofgdp1 fdi_inflows_ofgdp2 tradeof_gdp1 tradeof_gdp2  isds_respondent1_cum isds_respondent2_cum  bur_quality1 bur_quality2 gov_stability1 gov_stability2 if ln_gdp_difference >5.81792

eststo: reg effective_commitment dem_accountability1 c.dem_accountability1##c.prights_vdem2 polity1 polity2  yo_signature fdi_inflows_ofgdp1 fdi_inflows_ofgdp2 tradeof_gdp1 tradeof_gdp2  isds_respondent1_cum isds_respondent2_cum  bur_quality1 bur_quality2 gov_stability1 gov_stability2 if ln_gdp_difference<5.81792

esttab using apendix_table7.rtf, replace se  star(* .10 ** .05 *** .01)

